//
//  HeadInfoCell.m
//  掌上宏力
//
//  Created by admin on 2017/4/27.
//  Copyright © 2017年 admin. All rights reserved.
//

#import "HeadInfoCell.h"
#import "User.h"

NSString *const icon_url = @"http://www.honliv.com/lkoa/hrm/rsda/photo/";


@implementation HeadInfoCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

-(void)setHeadInfo{
    User *user = [User currentUser];
    NSString *iconUrl = [NSString stringWithFormat:@"%@%@.jpg",icon_url,user.userId];
    NSData *iconData = [NSData dataWithContentsOfURL:[NSURL URLWithString:iconUrl]];
    
    _iconV = [[UIImageView alloc] initWithFrame:CGRectMake(15, 15, 60, 70)];
    _iconV.layer.masksToBounds = YES;
    _iconV.layer.cornerRadius = 5;
    _iconV.image = [UIImage imageWithData:iconData];
    [self addSubview:_iconV];
    
    _nameL = [self createLableWithFrame:CGRectMake(_iconV.right+10, 18, 100, 30) text:user.username font:16];
    
    _departmentL = [self createLableWithFrame:CGRectMake(_iconV.right+10, _nameL.bottom, 200, 30) text:user.department font:16];
}
-(UILabel *)createLableWithFrame:(CGRect)frame text:(NSString *)text font:(CGFloat)font{
    UILabel *lab = [Factory createLabelWithTitle:text frame:frame fontSize:font];
    [self addSubview:lab];
    return lab;
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
